<?php

namespace App\Http\Resources;

use App\Helpers\BaseResource;
use App\Helpers\FileTool;

class Material extends BaseResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return $this->filterFields([
            'id' => hashid_encode($this->id),
            'path' => $this->data,
            'type' => $this->type,
            'url' => FileTool::thumb($this->data),
            'time' => (string)$this->created_at,
            'persistent_id' => $this->persistent_id,
            'fop_state' => (int)$this->fop_state,
            'key' => FileTool::thumb($this->key)
        ]);
    }
}
